<p>序列化<code> Serializable </code>类中的属性必须是<code> Serializable </code>或<code> transient </code>。
<h2>不规范代码示例</h2>
<pre>
public class Address {
  //...
}

public class Person implements Serializable {
  private static final long serialVersionUID = 1905122041950251207L;

  private String name;
  private Address address;  // Noncompliant; Address isn't serializable
}
</pre>

<h2>正确代码示例</h2>
<pre>
public class Address implements Serializable {
  private static final long serialVersionUID = 2405172041950251807L;
}

public class Person implements Serializable {
  private static final long serialVersionUID = 1905122041950251207L;

  private String name;
  private Address address;
}
</pre>

<h2>更多</h2>
<p>使所有成员均<code> serializable </code>或<code> transient </code>的替代方法是实施特殊方法，这些方法负责正确序列化和反序列化对象。该规则将忽略实现以下方法的类：</p>

<pre>
private void writeObject(java.io.ObjectOutputStream out) throws IOException
private void readObject(java.io.ObjectInputStream in) throws IOException, ClassNotFoundException;
</pre>

<h2>更多</h2>
    <ul>
      <li><a href="http://cwe.mitre.org/data/definitions/594.html">MITRE, CWE-594</a> - Saving Unserializable Objects to Disk</li>
      <li><a href="http://docs.oracle.com/javase/6/docs/api/java/io/Serializable.html">Oracle Java 6, Serializable</a></li>
      <li><a href="http://docs.oracle.com/javase/7/docs/api/java/io/Serializable.html">Oracle Java 7, Serializable</a></li>
    </ul>
